export default {
	BASE_URL : 'https://vapp.meide-casting.com/zhuzaomes/api',
	//封装uni.request()：
	deptId(){
		let user = uni.getStorageSync("user");
		return user.deptId;
	},
	factoryCode(){
		let user = uni.getStorageSync("user");
		return user.factoryCode;
	},
	user(){
		let user = uni.getStorageSync("user");
		return user;
	},
    request(options){
		console.log(options);
		// options.url  = "https://vapp.meide-casting.com/zhuzaomes/api" + options.url;
        return new Promise((resolve,reject)=>{
            //书写异步操作的代码
            uni.request({
                options,
                success:res=>{
                    if(options.native){
                        resolve(res)    //调取接口后返回的原生数据  
                    }
                    if(res.statusCode === 200){
                        resolve(res.data)   //异步操作执行成功
                    }else{
//                         console.log('请求的接口没有找到');
                        reject(res)     //异步操作执行失败
                    }
                }
            })
        })
    },
    get(url,data={},options={}){
        options.url=url;
        options.data=data;
        options.method='get';
        return this.request(options)
    },
    post(url,data={},options={}){
        options.url=url;
        options.data=data;
        options.method='post';
        return this.request(options)
    },
	  
	showToast(title){
			uni.showToast({
				title: title,
				icon:'success',
				duration:1000
			});
	},
	showToastErro(title){
			uni.showToast({
				title: title,
				icon:'erro',
				duration:2500
			});
	},
	navigateTo(path){
		uni.navigateTo({
			url:path
		})
	},
	switchTab(path){
		uni.switchTab({
			url:path
		})
	},
	redirectTo(path){
		uni.redirectTo({
			url:path
		})
	}
	
}